Fast text character set recognition

ABSTRACT

Methods and apparatus, including computer program products, for identifying a language corresponding to a string of data include receiving a data string and dividing the data string into coded character sequences for each of a plurality of languages. A length of one or more coded character sequences varies among different languages for coded character sequences having a particular number of characters. The coded character sequences are analyzed to calculate, for each of the plurality of languages, a probability that the data string corresponds to language. The calculated probabilities are compared among the languages, and a language is identified as corresponding to the data string based on the comparison.

BACKGROUND

The present invention relates to data processing by digital computer, and more particularly to identifying a language encoded in a data string.

Text is typically electronically stored as a string of data. The data string, for example, can represent text characters as code points having a hexadecimal byte value. The hexadecimal byte value maps to a particular character in one or more coded character sets. A character set describes a relationship between each character and a respective code point where each code point codes for a single character. There are a number of ISO character sets, for example, ISO 8859-1, which maps a set of Latin characters to their respective code points. Other character sets are created by different entities; for example, there are a number of Microsoft Windows character sets. FIG. 1 illustrates a character set for ISO 8859-1 (Latin 1). In byte form, each Latin 1 character has a one-byte hexadecimal code point value. For example, the letter “Ä” has a value of 0x41. The same code point value can correspond to different characters in different character sets. For example, the code point 0×CA corresponds to the symbol “Ä” in ISO 8859-1, but the same code point corresponds to the symbol “Δ” in ISO 8859-7 (Greek). Thus, the hexadecimal byte value defines a coordinate position for a character set but does not identify which character set of the available characters sets the value belongs. In other characters sets, a code point includes more than one byte.

Consequently, there can be a string of hexadecimal byte values that each define a position that exists in multiple different character sets. The identity of the character residing in the position corresponding to the hexadecimal byte value depends on the particular character set. As a result it is often difficult to identify the character itself without information in the data string identifying the language of the hexadecimal byte values, it can be difficult to determine the language corresponding to the data string. When translating the data string into another form, for example, into Unicode or to display the text, it is necessary to know the language corresponding to the data string.

SUMMARY OF THE INVENTION

The present invention provides methods and systems, including computer program products, that implement techniques for identifying a language from a string of data.

In general, in one aspect, the specification provides a method and computer program product for identifying a language corresponding to a string of data. The method includes receiving a data string, dividing the data string into coded character sequences for each of a plurality of languages, wherein a length of one or more coded character sequences varies among different languages for coded character sequences having a particular number of characters, analyzing the coded character sequences to calculate, for each of the plurality of languages, a probability that the data string corresponds to language, comparing the calculated probabilities among the languages, and identifying a language as corresponding to the data string based on comparing the calculated probabilities.

Implementations may include one or more of the following features. The data string can include a string of code points defining characters of a language. At least one of the code points can define a double-byte encoded character.

Dividing the data string can further include selecting, for each of the plurality of languages, a character set that maps characters to code points, identifying a first character set that includes characters encoded using a first number of bytes and a second character set that includes characters encoded using a second number of bytes and dividing the data string into coded character sequences corresponding to an equal number of characters but a different number of bytes for each of a first language corresponding to the first character set and a second language corresponding to the second character set. The data string can be divided, for each of the plurality of languages, into multiple sets of coded character sequences, with the coded character sequences in each set having a different number of characters from the coded character sequences in another of the sets. The calculated probability for each of the plurality of languages can include probabilities calculated for each of the multiple sets of coded character sequences. Each set of coded character sequences can be selected from the group consisting of a unigram, bi-gram, tri-gram, quarto-gram, and n-gram sequence with n having an integer value.

Identifying a language can further include identifying, as the language corresponding to the data string, a language having a calculated probability indicating that the data string is more likely, by at least a threshold amount, to correspond to the language than to correspond to any other language from the plurality of languages.

Analyzing the coded character sequences can further include identifying any nonvalid code points, if a coded character sequence for a language includes a nonvalid code point, determining that the data string does not correspond to the language, and if a coded character sequence for a language does not include nonvalid code points but does not match any coded character sequence in a collection of statistical information for the language, calculating the probability for the set of coded character sequences for the particular language without considering the particular coded character sequence. The nonvalid code points can include at least one of unused code points or illegal code points.

Comparing the calculated probabilities can further include performing a secondary analysis on the coded character sequences for languages having similar calculated probabilities. The secondary analysis can include using language characteristics to identify an unlikely character combination, and determining the language corresponding to the data string using the secondary analysis results.

In general, in another aspect, the specification provides a system for identifying a language corresponding to a string of data. The system includes means for receiving a data string, means for dividing the data string into coded character sequences for each of a plurality of languages, wherein a length of one or more coded character sequences varies among different languages for coded character sequences having a particular number of characters, means for analyzing the coded character sequences to calculate, for each of the plurality of languages, a probability that the data string corresponds to the language, means for comparing the calculated probabilities among the languages in the plurality of languages, and means for identifying a language as corresponding to the data string based on comparing the calculated probabilities.

The invention can be implemented to realize one or more of the following advantages. The process can identify languages from a data string. The process can identify double-byte encoded characters prior to analyzing the data string. Languages including double-byte characters such as Japanese, Chinese, and Korean can be identified from data string. The data string can be further analyzed after determining a probability in order to eliminate languages having illegal or unused code points. Secondary analysis can also be used to eliminate languages having similar probabilities. The secondary analysis can examine properties of the characters in order to eliminate languages. One implementation of the invention provides all of the above advantages.

Details of one or more implementations of the invention are set forth in the accompanying drawings and in the description below. Further features, aspects, and advantages of the invention will become apparent from the description, the drawings, and the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 illustrates a character set.

FIG. 2 is a flowchart illustrating a process for determining a language associated with a data string.

FIG. 3 is a flowchart illustrating a process for dividing a data string into coded character sequences.

FIGS. 4A and 4B illustrate a double-byte encoded character set.

FIG. 5 is a flowchart illustrating a process for analyzing coded character sequences for a plurality of languages.

FIG. 6 is a flowchart illustrating a process for comparing probabilities for different languages.

Like reference numbers and designations in the various drawings indicate like elements.

DETAILED DESCRIPTION

FIG. 2 illustrates a process 200 for determining a language associated with a data string. The process 200 begins following receipt of a data string (step 202). For example, the data string can be received by a computer over a network. The data string can include an encoding for a plurality of characters corresponding to a particular language. Different techniques for encoding a particular language are possible. In one implementation, the string of data includes a string of hexadecimal byte value code points corresponding to a particular language, although the data string may also include code points corresponding to more than one language and code points intermixed with other data. Assuming the string of code points represents a language, it may not be clear which language that the code points correspond to because the code points are represented in the data string as hexadecimal byte values that are not unique for each language. Each code point is represented by hexadecimal byte values. If the language is unknown, the data string is processed to identify the language.

After receiving the data string, a plurality of languages are selected as potentially corresponding to the data string (step 204). For example, in one implementation, the data string is analyzed under a presumption that it includes code points corresponding to one particular language from a set of candidate languages. The presumption can be tested through analysis to identify the correct language. For each potential language, the data string is divided into a plurality of coded character sequences (step 206). Each coded character sequence includes one or more code points. The length of the coded character sequences, or number of bytes, for a particular number of characters can vary depending on the language presumed for the data string. For example, a single Latin character is typically represented by a code point with a single byte length, while a single character in an Asian langue is typically represented by a code point with a double byte length.

As shown in FIG. 2, after the data string is divided into a plurality of coded character sequences having a particular character length, each coded character sequence is analyzed to determine a probability that the coded character sequence belongs to the particular language presumed to be associated with the data string (step 208). To determine the probability for each coded character sequence, the character or character combination contained within each coded character sequence is compared with statistical information for that language.

A mathematical relationship can exist between the frequency at which a character occurs in a language sample and the overall rank of the character in the sample. The relationship between frequency and rank exists in different languages as well as in text samples broken up into different numbers of characters or even words. In one implementation, the use of a large sample text can be used to generate the statistical relationship for a particular language based on a particular number of characters. Consequently, the relationship between frequency and rank for text samples of different character numbers and different languages can be used to determine a probability that certain character combinations belong to a specific language.

For example, for a sample of Latin characters in English, the frequency/rank relationship can be calculated for different two letter combinations, e.g., AB, BC, CD, DE, EF. Thus, the frequency of the character combination AB in a sample is calculated, not the frequency of A and B separately. A number of statistics can be generated for each language, for example a statistic for character numbers 1-n in an n-byte sequence. Therefore, the analysis can be performed on coded character sequences representing different numbers of characters.

The information from the statistical analysis can be used to generate statistical information describing the probability of different characters and/or character combinations occurring for a given language. For each language, a statistical table can be generated that illustrates different character combinations and each respective probability. Using, for example, a lookup table of the statistical information for the language and number of characters in a coded character sequence, the probability for each particular coded character sequence can be calculated.

The code points corresponding to certain characters can be common in one language while rare in others. For example, the code point 0x49 in Latin 1 represents the commonly used letter “I” in English. However, 0x49 can map a character that is either used infrequently or not at all in other languages. If a code point maps a character that is commonly used in one language but not in others, it is more likely that a coded character sequence including that code point belongs to the language in which it is more commonly used. Therefore, the probability represents the likelihood that the character or characters of the coded character sequence belong to a particular language.

Once the probability for each coded character sequence is calculated, an overall probability that the data string corresponds to a particular language can also be calculated. For example, in one implementation, the overall probability is calculated as the product of the probabilities for each coded character sequence. Other mathematical means for calculating a combined probability can be used. Different numbers of coded character sequences can be analyzed, and it is not required to analyze every coded character sequence for a given string of code points. However, using more coded character sequences reduces the likelihood of erroneously selecting an incorrect language caused by not having a comprehensive analysis. For example, if only one coded character sequence is examined, the statistic can indicate a high probability that the code points belong to one language over another. However, it is possible that the coded character sequence actually belongs to a different language having a lower probability, but the coded character sequence used happened to relate to a valid but less frequently used character or character combination for that language. The use of several, or all of the coded character sequences from a string of code points reduces the probability of a mistaken language selection. An overall probability that the data string corresponds to a particular language is calculated for each language (step 210).

After determining the overall probabilities for each language, the probabilities can be compared to determine the language that the string of code points corresponds to (step 212). Based on the comparison of probabilities, the correct language corresponding to the string of code points can be selected (step 214).

A process 300 for dividing the data string is illustrated in FIG. 3. For each language, a corresponding character set is identified that maps characters from that language to the presumed code points in the data string (step 302). For some languages, more than one character set can be identified. In some character sets, such as ISO 8859-1, each character is defined by one single byte value code point, for example, the letter “A” represented as 0x41. However, for other languages, the corresponding character set includes characters that are defined by a pair of bytes. Thus, it takes two singe byte hexadecimal values to define each character. These characters are said to be double-byte encoded. Several Asian languages, such as Japanese and Chinese include double-byte encoded characters.

An example of a character set including double-byte characters is illustrated in FIGS. 4A and 4B. FIG. 4A illustrates a portion of a Japanese character set. Several code point portions are designated as lead bytes 402 for double-byte encoded characters. The lead byte makes up half of the hexadecimal byte required to define the character. Lead byte 404, corresponding to 0x8E is the lead byte for the characters shown in FIG. 4B. The characters shown in FIG. 4B are double-byte encoded characters. For example, the upper left character can be represented as 0x8E+0x40, or the shortened form of 8E40.

The character set is used to identify any code points in the data string that correspond to a double-byte encoded character (step 304). Once any code points corresponding to double-byte encoded characters have been identified, the data string can be divided into a plurality of coded character sequences (step 306). Each coded character sequence includes one or more code points where each code point corresponds to a single character. For example, in one implementation, each coded character sequence includes two code points corresponding to two characters. However, even if the number of characters is constant, the length of the coded character sequences can vary depending on the inclusion of any double-byte characters in the string of bytes. For example, in a single-byte encoded character set, two characters can be represented by two bytes. In another example, if the character set includes both single byte and double-byte characters, two characters can be represented by 2-4 bytes depending on the encoding for each character. As a result, the length of the coded character sequences can differ depending on the character set used.

The data string is divided into a plurality of bytes sequences for each language. Therefore, the length of the coded character sequences can vary depending on the language because some languages are single-byte encoded and other languages are double-byte encoded. The number of characters included in each coded character sequence can also be varied in different implementations. In one implementation, the data string is divided into several sets of coded character sequences for each language, each set having coded character sequences of a distinct number of characters (step 308). For example, the data string can be broken up in different ways to produce coded character sequences having a particular number of characters, e.g., uni-gram, bi-gram, tri-gram, or quarto-gram representing coded character sequences having 1, 2, 3, and 4 characters respectively. For example, if the data string is ABCDEF, the data string can be divided in to coded character sequences of A, B, C, D, E, F; AB, CD, EF; and ABC, DEF. The analysis can then be performed for each language using coded character sequences having an equal number of characters, or alternatively, the analysis can be performed taking into account dividing the data string into different numbers of characters. A probability calculation can be performed for each division of the data string. An overall probability can be calculated as part of step 210 using the different probabilities of data string based on different numbers of characters.

In one implementation, if the probability for a particular coded character sequence is calculated to be zero, a secondary analysis is performed on the coded character sequence as part of step 210 discussed above (see FIG. 2). FIG. 5 illustrates a process 500 for analyzing a coded character sequence when one or more coded character sequences has a calculated probability of zero. The process begins by calculating the probability for each coded character sequence (step 502). The calculated probability for each coded character sequence is examined to determine if the calculated probably is zero for any coded character sequences (step 504). If the calculated probability for a coded character sequence is zero, the code points can be further analyzed. The code points in the coded character sequence can be compared with the code point definitions of the character set to identify any illegal or unused code points in the coded character sequence (step 506). Each character set includes code points having a specific range of values. For example, Latin 1 has a range of code point values from 0x00 to 0xFF (FIG. 1). Illegal code points are code points that have a value defined outside the range of values for that character set. For example, a code point having a value of 0xEEF in Latin 1 is an illegal code point because it is not within the defined range for the Latin 1 character set. An illegal code point can indicate that the presumed language does not match the data string or that the data string or portion thereof is not defining language characters. For example, the string of data can be binary data. Unused code points are code points within the range of code point values for a character set, but the particular code point is not defined in the character set. For example, the character set for Latin 1 includes blank spaces for unused code points e.g., 0x81.

If the character set is eliminated because a code point does not correspond to a character within the character set, then the data string (or at least a portion thereof) does not belong to the language represented by the character set. If a coded character sequence includes an unused or illegal code point, the language or languages corresponding to the character set are eliminated from consideration (step 508). If an unused or illegal code point is found in a particular coded character sequence, the particular coded character sequence can be eliminated from the overall probability calculation for the string of code points (step 510). If none of the coded character sequences have a probability equal to zero, the processing of the string of code points continues, for example, by comparing the probabilities for different languages (step 512).

In some cases, the probability for a coded character sequence can be zero without having any unused or illegal code points. The probability can be zero because the particular character combination in the coded character sequence is valid but was not included in the calculation statistic. For example, if the particular character combination is rare, the sample text used to generate the statistic may not have included the character combination even though the character combination is valid. If the probability is zero and the coded character sequence does not include any illegal or unused code points, the coded character sequence can be omitted from the calculation of the overall probability for the data string so that the overall probability is nonzero (step 510). Therefore, by identifying unused and illegal code points, some languages can be omitted from further consideration. Additionally, the secondary analysis can be used to eliminate other sources of zero probabilities.

FIG. 6 illustrates a process 600 for comparing the overall probabilities for different languages. The process begins with the calculation of probabilities for each language (step 602). The probabilities are compared to determine whether the calculated probability for one language is significantly greater than the probabilities for the other languages (step 604). If the difference in probabilities is greater than a predetermined threshold, a selection of the language having the greatest probability can be made without further comparison (step 606). The threshold difference can be, for example, and absolute difference between the probabilities, a percentage difference, a scaled difference, or some other amount. In one implementation, the language associated with the greatest probability is selected regardless of the difference between probabilities. In other implementations, however, there can be more than one probability that is closely related to another probability such that the language cannot be determined without further analysis (step 608). For example, the difference between the probabilities is less than the threshold amount. A secondary analysis can be performed on the coded character sequences for the languages having similar probabilities (step 610).

The secondary analysis can apply different functions on presumed characters, corresponding to the code points in the coded character sequences, that use information about different character properties to eliminate languages. In one implementation, a function called ISALPHA is applied to the coded character sequences. The ISALPHA function can determine whether or not each code point in the coded character sequences correspond to a text character or a symbol in the character set. The context provided by surrounding characters can be used to determine whether or not a symbol can be present in a given position relative to other code points. For example, if the probability for a string of code points is similar for both ISO 8859-1 (Latin 1) and ISO 8859-2 (Latin 2) character sets, a function called ISALPHA can be used to eliminate one of the character sets. One of the code points can represent a language character in one character set and a symbol in another character set. For example, the code point 0xB6 represent “ś” in Latin 2 and “¶” in Latin 1. By examining the surrounding code points it can be determined that the code point is part of a word, which in Latin 2 is “Ksi

gowość” and in Latin 1 is “Ksi

gowo¶æ”. Because it is unlikely that ¶ is part of a word, while Ksi

gowość is the word for “accounting” in Polish, the Latin 1 character set can be eliminated and a the language can be selected as Latin 2 corresponding to Polish.

If a code point represents a symbol in, for example, two different character sets having similar probabilities, the context of related code points can again be used to determine the correct character set. For example, the code point 0xA2 represents “c/” in Latin 1 and “{hacek over ( )}” in Latin 2. The character {hacek over ( )} can not stand alone and must be coupled to a particular character or characters while c/ can stand alone without any other required characters. Therefore, if there are not code points adjacent to {hacek over ( )} which are required for the symbol to be present, the symbol must instead be c/ and the Latin 2 character set can therefore be eliminated.

Other techniques or functions can be used to provide a secondary analysis to the code points to select the correct language for the data string. The language is then selected based on the secondary analysis (step 612). Once the language has been identified, other processes can then occur. For example, after determining the language, the string of code points can be translated, for example into text characters for display or into Unicode for transmission.

The invention and all of the functional operations described in this specification can be implemented in digital electronic circuitry, or in computer software, firmware, or hardware, including the structural means disclosed in this specification and structural equivalents thereof, or in combinations of them. The invention can be implemented as one or more computer program products, i.e., one or more computer programs tangibly embodied in an information carrier, e.g., in a machine-readable storage device or in a propagated signal, for execution by, or to control the operation of, data processing apparatus, e.g., a programmable processor, a computer, or multiple computers. A computer program (also known as a program, software, software application, or code) can be written in any form of programming language, including compiled or interpreted languages, and it can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment. A computer program does not necessarily correspond to a file. A program can be stored in a portion of a file that holds other programs or data, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code). A computer program can be deployed to be executed on one computer or on multiple computers at one site or distributed across multiple sites and interconnected by a communication network.

The processes and logic flows described herein, including the method steps of the invention, can be performed by one or more programmable processors executing one or more computer programs to perform functions of the invention by operating on input data and generating output. The processes and logic flows can also be performed by, and apparatus of the invention can be implemented as, special purpose logic circuitry, e.g., an FPGA (field programmable gate array) or an ASIC (application-specific integrated circuit).

Processors suitable for the execution of a computer program include, by way of example, both general and special purpose microprocessors, and any one or more processors of any kind of digital computer. Generally, a processor will receive instructions and data from a read-only memory or a random access memory or both. The essential elements of a computer are a processor for executing instructions and one or more memory devices for storing instructions and data. Generally, a computer will also include, or be operatively coupled to receive data from or transfer data to, or both, one or more mass storage devices for storing data, e.g., magnetic, magneto-optical disks, or optical disks. Information carriers suitable for embodying computer program instructions and data include all forms of non-volatile memory, including by way of example semiconductor memory devices, e.g., EPROM, EEPROM, and flash memory devices; magnetic disks, e.g., internal hard disks or removable disks; magneto-optical disks; and CD-ROM and DVD-ROM disks. The processor and the memory can be supplemented by, or incorporated in special purpose logic circuitry.

The invention can be implemented in a computing system that includes a back-end component (e.g., a data server), a middleware component (e.g., an application server), or a front-end component (e.g., a client computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the invention), or any combination of such back-end, middleware, and front-end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (“LAN”) and a wide area network (“WAN”), e.g., the Internet.

The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.

The invention has been described in terms of particular embodiments, but other embodiments can be implemented and are within the scope of the following claims. For example, the operations of the invention can be performed in a different order and still achieve desirable results. In certain implementations, multitasking and parallel processing may be preferable. Other embodiments are within the scope of the following claims. 

What is claimed is:
 1. A method for identifying a language corresponding to a string of data, comprising: receiving a data string from memory, the data string comprising a string of code points defining characters of a language where one or more of the code point values corresponds to more than one distinct character set, the data string having been electronically stored in the memory; dividing the data string into a plurality of coded character sequences for each of a plurality of languages to represent the same number of characters in each language of the plurality of languages, wherein a length of one or more coded character sequences varies among different languages; analyzing the coded character sequences to calculate, for each of the plurality of languages, an overall probability that the data string corresponds to a particular language, the analyzing coded character sequences for each language including: calculating a probability for each coded character sequence using statistical information, the probability being the probability that the particular coded character sequence corresponds to the language, determining that a probability for any of the coded character sequences is zero, comparing a code point of a coded character sequence having a probability of zero to respective code point definitions of each of the plurality of languages to affect a comparison, determining that the coded character sequence includes illegal code points for at least one language of the plurality of languages based on the comparison and eliminating the at least one language as a language to which the coded character sequence could correspond, removing the probability from an overall probability calculation when determining that the probability is zero and that the coded character sequence does not include an illegal code point, and using the probabilities to calculate the overall probability that the data string corresponds to the language; comparing the calculated overall probabilities among the languages; and identifying a language as corresponding to the data string based on comparing the calculated overall probabilities.
 2. The method of claim 1, wherein at least one of the code points defines a double-byte encoded character.
 3. The method of claim 1, wherein dividing the data string further comprises: selecting, for each of the plurality of languages, a character set that maps characters to code points; identifying a first character set that includes characters encoded using a first number of bytes and a second character set that includes characters encoded using a second number of bytes; and dividing the data string into coded character sequences corresponding to an equal number of characters but a different number of bytes for each of a first language corresponding to the first character set and a second language corresponding to the second character set.
 4. The method of claim 3, wherein the data string is divided, for each of the plurality of languages, into multiple sets of coded character sequences, with the coded character sequences in each set having a different number of characters from the coded character sequences in another of the sets.
 5. The method of claim 4, wherein the calculated overall probability for each of the plurality of languages comprises probabilities calculated for each of the multiple sets of coded character sequences.
 6. The method of claim 4, wherein each set of coded character sequences is selected from the group consisting of a unigram, bi-gram, tri-gram, quarto-gram, and n-gram sequence with n having an integer value.
 7. The method of claim 1, wherein identifying a language further comprises: identifying, as the language corresponding to the data string, a language having a calculated overall probability indicating that the data string is more likely, by at least a threshold amount, to correspond to the language than to correspond to any other language from the plurality of languages.
 8. The method of claim 1, wherein analyzing the coded character sequences further comprises: identifying any unused code points; when a coded character sequence for a language includes an unused code point, determining that the data string does not correspond to the language; and when a coded character sequence for a language does not include unused code points but does not match any coded character sequence in a collection of statistical information for the language, calculating the overall probability for the set of coded character sequences for the particular language without considering the particular coded character sequence.
 9. The method of claim 1, wherein comparing the calculated overall probabilities further comprises: performing a secondary analysis on the coded character sequences for languages having similar calculated probabilities, including: using language characteristics to identify an unlikely character combination; and determining the language corresponding to the data string using the secondary analysis results.
 10. A system for identifying a language corresponding to a string of data, comprising: one or more processors; and a non-transitory computer-readable storage medium coupled to the one or more processors having instructions stored thereon which, when executed by the one or more processors, cause the one or more processors to perform operations comprising: receiving a data string comprising a string of code points defining characters of a language where one or more of the code point values corresponds to more than one distinct character set; dividing the data string into coded character sequences for each of a plurality of languages to represent the same number of characters in each language of the plurality of languages, wherein a length of one or more coded character sequences varies among different languages; analyzing the coded character sequences to calculate, for each of the plurality of languages, an overall probability that the data string corresponds to a particular language, the analyzing coded character sequences for each language including: calculating a probability for each coded character sequence using statistical information, the probability being the probability that the particular coded character sequence corresponds to the language, determining that a probability for any of the coded character sequences is zero, comparing a code point of a coded character sequence having a probability of zero to respective code point definitions of each of the plurality of languages to affect a comparison, determining that the coded character sequence includes illegal code points for at least one language of the plurality of languages based on the comparison and eliminating the at least one language as a language to which the coded character sequence could correspond, removing the probability from an overall probability calculation when determining that the probability is zero and that the coded character sequence does not include an illegal code point, and using the probabilities to calculate the overall probability that the data string corresponds to the language; comparing the calculated overall probabilities among the languages in the plurality of languages; and identifying a language as corresponding to the data string based on comparing the calculated overall probabilities.
 11. A non-transitory machine-readable storage device encoded with a computer program product for identifying a language corresponding to a string of data, the computer program product being operable to cause a data processing apparatus to perform operations comprising: receiving a data string comprising a string of code points defining characters of a language where one or more of the code point values corresponds to more than one distinct character set; dividing the data string into a plurality of coded character sequences for each of a plurality of languages to represent the same number of characters in each language of the plurality of languages, wherein a length of one or more coded character sequences varies among different languages; analyzing the coded character sequences to calculate, for each of the plurality of languages, an overall probability that the data string corresponds to a particular language, the analyzing coded character sequences for each language including: calculating a probability for each coded character sequence using statistical information, the probability being the probability that the particular coded character sequence corresponds to the language, determining that a probability for any of the coded character sequences is zero, comparing a code point of a coded character sequence having a probability of zero to respective code point definitions of each of the plurality of languages to affect a comparison, determining that the coded character sequence includes illegal code points for at least one language of the plurality of languages based on the comparison and eliminating the at least one language as a language to which the coded character sequence could correspond, removing the probability from an overall probability calculation when determining that the probability is zero and that the coded character sequence does not an include illegal code point, and using the probabilities to calculate the overall probability that the data string corresponds to the language; comparing the calculated overall probabilities among the languages; and identifying a language as corresponding to the data string based on comparing the calculated overall probabilities.
 12. The non-transitory storage device of claim 11, wherein dividing the data string further includes operations comprising: selecting, for each of the plurality of languages, a character set that maps characters to code points; identifying a first character set that includes characters encoded using a first number of bytes and a second character set that includes characters encoded using a second number of bytes; and dividing the data string into coded character sequences corresponding to an equal number of characters but a different number of bytes for each of a first language corresponding to the first character set and a second language corresponding to the second character set.
 13. The non-transitory storage device of claim 12, wherein the data string is divided, for each of the plurality of languages, into multiple sets of coded character sequences, with the coded character sequences in each set having a different number of characters from the coded character sequences in another of the sets.
 14. The non-transitory storage device of claim 13, wherein the calculated overall probability for each of the plurality of languages comprises probabilities calculated for each of the multiple sets of coded character sequences.
 15. The non-transitory storage device of claim 13, wherein each set of coded character sequences is selected from the group consisting of a unigram, bi-gram, tri-gram, quarto-gram, and n-gram sequence with n having an integer value.
 16. The non-transitory storage device of claim 11, wherein identifying a language further includes operations comprising: identifying, as the language corresponding to the data string, a language having a calculated overall probability indicating that the data string is more likely, by at least a threshold amount, to correspond to the language than to correspond to any other language from the plurality of languages.
 17. The non-transitory storage device of claim 11, wherein analyzing the coded character sequences includes operations comprising: identifying any unused code points; when a coded character sequence for a language includes an unused code point, determining that the data string does not correspond to the language; and when a coded character sequence for a language does not include unused code points but does not match any coded character sequence in a collection of statistical information for the language, calculating the overall probability for the set of coded character sequences for the particular language without considering the particular coded character sequence.
 18. The non-transitory storage device of claim 11, wherein comparing the calculated overall probabilities further includes operations comprising: performing a secondary analysis on the coded character sequences for languages having similar calculated probabilities, including: using language characteristics to identify an unlikely character combination; and determining the language corresponding to the data string using the secondary analysis results. 